Conversation
in2lambda/wizard/mathpix.py: pdf_to_markdown() uploads a PDF to the Mathpix OCR API, polls for the rendered markdown, downloads any remote figures into <out_dir>/media/, and repoints the markdown at ./media/<name> so the Markdown filter's image resolution finds them. - Credentials from $MATHPIX_APP_ID / $MATHPIX_API_KEY; a missing pair raises a clear RuntimeError. - Only needs `requests` (already a core dep), so the module imports without the llm extra. - Ported and cleaned up from conversion2025/converter.py on Summer2025: print/exit calls become exceptions, the PIL round-trip is dropped (bytes are streamed straight to disk), poll interval/count are parameters. Tests mock all HTTP. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017VXb8aZqgFBjoeuuddjW6r
|
Notes from review. The shape of this is fine; it's the failure paths that need work before it goes near a real PDF. No timeouts. None of the three HTTP calls ( Polling treats every failure as "not ready yet" (
It can overwrite a file the user cares about. Failed figure downloads are skipped silently ( Two more, both worth a line in the docs rather than code: the PDF is uploaded to a third party, which teachers should be told about, and Mathpix has a training opt-out that we probably want set. Also, has this been run against the real service yet? The tests mock it, so what they check is our assumptions about the API rather than the API itself. |
in2lambda/wizard/mathpix.py:pdf_to_markdown()uploads a PDF to the Mathpix OCR API, polls for the rendered markdown, downloads any remote figures into<out_dir>/media/, and repoints the markdown at./media/<name>so the Markdown filter's image resolution finds them.$MATHPIX_APP_ID/$MATHPIX_API_KEY; a missing pair raises a clearRuntimeError.requests(already a core dep), so the module imports without thellmextra.conversion2025/converter.pyonSummer2025: print/exit calls become exceptions, the PIL round-trip is dropped (bytes stream straight to disk), poll interval/count are parameters.Stack: llm-client ← mathpix ← wizard-command
Base:
llm-client— #25.🤖 Generated with Claude Code